home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4678 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.9 KB  |  48 lines

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: void main() and other atrocities!
  5. Date: Tue, 06 Feb 96 13:17:06 GMT
  6. Organization: none
  7. Message-ID: <823612626snz@genesis.demon.co.uk>
  8. References: <4eduaj$1aq@grouper.Exis.Net> <4em17r$shq@jaxnet.jaxnet.com> <4emub9$1mo@fountain.mindlink.net> <4epplj$egf@host-3.cyberhighway.net> <4erjn2INN38b@keats.ugrad.cs.ubc.ca> <9602021300.AA04359@dxmint.cern.ch> <4f5vc2$qcj@cdn_news.telecom.com.au>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <4f5vc2$qcj@cdn_news.telecom.com.au>
  15.            jolson@vprpmel1.telecom.com.au "Jeff Olson" writes:
  16.  
  17. >How about:
  18. >
  19. >int main (int argc, char **argv)
  20. >
  21. >I saw in the FAQ that a multi-dimentional array will not decay into a pointer 
  22. >to a pointer.  This main() is valid with my Sparcworks compiler so I would 
  23. >like to know if my compiler is supporting non-standard behavior or if argv is 
  24. >a pointer to an array of characters (meaning it can decay into a pointer to a 
  25. >pointer).
  26.  
  27. argv is correctly a pointer to a pointer. The standard writes the 2 parameter
  28. form of main as
  29.  
  30. int main(int argc, char *argv[]) { /*...*/ }
  31.  
  32. The type of argv stated here is an array of pointers to char. By the function
  33. parameter rewrite rule the compiler treats this exactly as if it were
  34. written as:
  35.  
  36. int main(int argc, char **argv) { /*...*/ }
  37.  
  38. However the important thing to note is that the 'argv array' is genuinely
  39. an array of pointers (and is not an array of arrays) so it is correct that
  40. argv itself is a pointer to a pointer. If you were to call main you couldn't
  41. legally pass it an array of arrays.
  42.  
  43. -- 
  44. -----------------------------------------
  45. Lawrence Kirby | fred@genesis.demon.co.uk
  46. Wilts, England | 70734.126@compuserve.com
  47. -----------------------------------------
  48.